#ifndef DOORMODE_H
#define DOORMODE_H

#include <QWidget>
#include <QTimer>

namespace Hydra_DoorMode {
typedef enum _door_mode
{
    INIT,                                       // 初始态
    MM,                                         // 人工开/人工关
    AM,                                         // 自动开/人工关
    AA                                          // 自动开/自动关
}DOORMODE;
}

using namespace Hydra_DoorMode;

class DoorMode : public QWidget
{
    Q_OBJECT

public:
    DoorMode(QWidget *parent = 0);

    void setInterval(quint16 interval);
    void setDoorState(DOORMODE state);

public slots:
    void refresh();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);
    void initParam();
    void drawImage(QPainter *pPainter);
    void drawDoor(QPainter *pPainter);
    void drawText(QPainter *pPainter);



private:
    QTimer mTimer;                                                              // 计时器
    QPoint mCenterPoint;                                                        // 控件中心点
    quint8 mImageHeightProportion = 70;                                         // 图形高度占控件高度百分比
    quint8 mImageWidthProportion = 55;                                          // 图形宽度占控件宽度百分比
    quint8 mDoorWidthProportion = 20;                                           // 门宽度占图形宽度百分比
    QRect mDoorOutSideRect;                                                     // 门外矩形
    QRect mDoorInSideRect;                                                      // 门内矩形
    quint8 mInSideOutSideProportion = 65;                                       // 内外圆比例
    quint8 mSpacing = 2;                                                        // 内外矩形的空隙
    QRect mTextRect;                                                            // 文本矩形
    QColor mImageColor = QColor(212, 212, 212);                                 // 图形颜色
    DOORMODE mState = DOORMODE::INIT;                                           // 门模式状态
    QString mMMStr = "MM";
    QString mAMStr = "AM";
    QString mAAStr = "AA";
    QString mStrFontFace = "Arial";                                             // 文字字体
    quint8 mStrFontWeight = 3;
};

#endif // DOORMODE_H
